package com.sgb.kjwl.view.ui.adapter.search;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.user.SearchSTEntity;
import com.sgb.kjwl.view.ui.activity.manage.ShopInfoForCompanyTradesActivity;
import com.sgb.kjwl.view.ui.activity.self.shop.ShopInfoActivity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class SearchSTAdapter extends BaseRecycleAdapter<SearchSTEntity> {

    private TextView contentView;
    private TextView priceView;
    private TextView brand;
    private TextView arrow_view;

    public SearchSTAdapter(Context context, List<SearchSTEntity> datas) {
        super(context, R.layout.item_search_st, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final SearchSTEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        contentView = holder.getItem().findViewById(R.id.content_view);
        brand = holder.getItem().findViewById(R.id.brand);
        priceView = holder.getItem().findViewById(R.id.price_view);
        arrow_view = holder.getItem().findViewById(R.id.arrow_view);
//        Glide.with(context).load(entity.getImage()).into((ImageView) holder.getItem().findViewById(R.id.logo_view));
        priceView.setText("￥ " + entity.getPrice() + "/" + entity.getUnit());
        arrow_view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ShopInfoForCompanyTradesActivity.startAct(context, entity.getProviderId(), "", 0, 0);
            }
        });
    }
}
